<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        div{
            width: 350px;
            outline: solid 1px red;
            margin-left: auto;
            margin-right: auto;
            margin-top: 100px;
        }
        #text1{
            width: 140px;
            font-size: 25px;
            outline: solid 1px blue;
            background-color: cornflowerblue;
            float: left;
        }
        span{
            width: 80px;
            height: 30px;
            font-size: 25px;
            outline: solid 1px red;
            float: left;
            overflow: hidden;
            margin-left: 10px;
        }
        #span2{

            font-size: 20px;
            width: 100px;
        }
        #span1{
            background-color: lavenderblush;
        }
        span:hover{
            cursor: pointer;
        }
        #span3{
            clear: both;
        }
    </style>
    <script>
        function show(obj) {
            var code = obj.value;
            var span1 = document.getElementById("span1");
            span1.innerHTML = code;
        }
    </script>
</head>
<body>
<div>
   <input type="text" id="text1" placeholder="请输入信息" onkeyup="show(this)"> <span id="span1"></span>
   <span id="span2" onclick="show()">获取验证码</span><p id="span3"></p>
</div>
</body>
</html>